#include <iostream>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

using namespace std;

EXEC SQL BEGIN DECLARE SECTION;

VARCHAR   username[20];
VARCHAR   password[20];

int       DS_DeptNum;
VARCHAR   DS_DeptName[30];
VARCHAR   DS_DeptLocation[30];
VARCHAR   DS_DeptPhone[12];

int       DS_FacNum;
int       DS_FacYearStart;
VARCHAR   DS_FacName[20];
VARCHAR   DS_FacRank[4];

int       DS_IDeptName;
int       DS_IFacNum;
VARCHAR   DS_IOffice[30];
VARCHAR   DS_IPhone[12];

EXEC SQL END DECLARE SECTION;

EXEC SQL INCLUDE SQLCA;

void connect();
void buildSqlSelect();
void prepareExecute();
void printResults();
void commitAndExit();
void sqlErrorHandle(char *);

int main()
{
  EXEC SQL WHENEVER SQLERROR do sqlErrorHandle("***Oracle Error:  ");

  connect();

  buildSqlSelect();

  prepareExecute();

  commitAndExit();

  return 0;
}

void connect()
{

  char* temp_password;

  cout << "Enter Oracle Username: ";
  cin >> username.arr;

  temp_password = getpass("Enter Oracle Password: ");
  strcpy((char*)password.arr, temp_password);

  username.len = strlen( (char*) username.arr );
  password.len = strlen( (char*) password.arr );

  EXEC SQL CONNECT :username IDENTIFIED BY :password;

  cout << "Connected to Oracle as user: " << (char*) username.arr << endl << endl;

}

void buildSqlSelect()
{
  strcpy( (char*) sqlStatement.arr, "
